/*
 *  Copyright (C) 2011  Clint Priest
 *
 *  This file is part of pklib.
 *
 *  pklib is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  pklib is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with pklib.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

var HtmlDocument;

function $doc() {
	if(!HtmlDocument) {
		HtmlDocument = document;
		if(HtmlDocument.location.href.indexOf('chrome') != -1)
			try { HtmlDocument = HtmlDocument.getElementById('content').contentDocument; } catch(e) { }
	}
	return HtmlDocument;
}

function CreateAnonymousElement(markup) {
	var AnonymousElement = $((new DOMParser())
		.parseFromString('<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">'+markup+'</overlay>', 'text/xml')
		.firstChild
		.firstChild);
	AnonymousElement.parentNode.removeChild(AnonymousElement);
	return AnonymousElement;
}
